import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { viteStaticCopy } from "vite-plugin-static-copy";

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    viteStaticCopy({
      targets: [
        { src: "manifest.json", dest: "." },
        { src: "src/background.js", dest: "src" },
        { src: "src/content-script.js", dest: "src" },
        { src: "src/content-script.js", dest: "src" },
        { src: "src/image/*", dest: "src/image" },
      ],
    }),
  ],
  build: {
    publicDir: false, // 新增：禁用Vite默认的public目录处理
    rollupOptions: {
      output: {
        entryFileNames: "[name].js",
        chunkFileNames: "[name].js",
        assetFileNames: "[name].[ext]",
      },
    },
  },
});
